@extends('admin.layout.layout')
@section('title','商店列表')
@section('con')
<div id="page-wrapper" style="min-height: 349px;">
    <div class="row">
        <div class="col-lg-12">
            <h1 class="page-header">商店列表</h1>
        </div>
        <!-- /.col-lg-12 -->
    </div>
    <!-- /.row -->
    <div class="row">
        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    商店列表
                </div>
                <!-- /.panel-heading -->
                <div class="panel-body">
                    <div class="dataTable_wrapper">
                        <div id="dataTables-example_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
                            <div class="row">
                                <form action="{{url('/admin/shop/index')}}">
	                                <div class="col-sm-8">
	                                </div>
	                                <div class="col-sm-4">
		                                <div id="dataTables-example_filter" class="dataTables_filter">
			                                <label>搜索:
			                                	<input name="keywords" value="{{ $list['keywords'] or '' }}" type="search" class="form-control input-sm" placeholder="请输入商店关键字" aria-controls="dataTables-example" />
			                                </label>
			                                <button class="btn btn-sm btn-primary" >查询</button>
		                               	</div>
	                                </div>
                                 </form>
                            </div>
                            <div class="row">
                            	<div class="col-sm-12">
                            		<table class="table table-striped table-bordered table-hover dataTable no-footer" id="dataTables-example" role="grid" aria-describedby="dataTables-example_info">
                                		<thead>
                                			<tr>
	                                    		<th>商店ID</th>
	                                    		<th>商店名</th>
	                                    		<th>商店图</th>
	                                    		<th>商店地址</th>
	                                    		<th style="width:150px;">操作</th>
                                			</tr>
                                		</thead>
                                    	<tbody>
                                    		@foreach($shops as $k=>$v)
		                                    <tr class="gradeA odd" role="row" >
		                                        <td class="sorting_1">{{$v->sid}}</td>
		                                        <td data-toggle="modal" data-target="#myModal_{{$v->sid}}">{{$v->sname}}</td>
		                                        <td class="center"><img style="width:30px" src="{{asset($v->spic)}}" alt=""></td>
		                                        <td class="center" style="width: 310px"><div style="width:300px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">{{$v->surl}}</div></td>
		                                        <td class="center">
				                                	<a href="/admin/shop/edit?id={{$v->sid}}" class="btn btn-outline btn-primary" type="button">修改</a>
				                                	<button class="btn btn-outline btn-danger del" type="button">删除</button>
		                                        </td>
		                                    </tr>

		                                    <!-- 详情 模态框 -->
											<div class="modal fade" id="myModal_{{$v->sid}}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
												<div class="modal-dialog">
													<div class="modal-content">
														<div class="modal-header">
															<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
															<h4 class="modal-title" id="myModalLabel">商店详情</h4>
														</div>
														<div class="modal-body">
															<div class="row">
										                        <div class="col-lg-12">
										                        	<div class="form-group">
										                        		<h2>{{$v->sname}}</h2>
										                        	</div>
										                        	<br><br>
										                        	<div class="form-group ">
										                        	</div>
										                    	</div>
															</div>
														</div>
													<div class="modal-footer">	
														<a href="{{$v->surl}}" class="btn btn-outline btn-danger" target="_blank" >直达链接</a>
													</div>
												</div>
											</div>			
		                                    <!-- 模态框 -->
		                                    @endforeach
                                    	</tbody>
                            		</table>
                            	</div>
                            </div>
                            <!-- 分页 -->
                            <div class="row">
	                   			<div style="margin:0px auto">
	                   				{!! $shops->appends($list)->render() !!}
	                   			</div>
	                   		</div>
                        </div>
                	</div>
            	</div>
        	</div>
    	</div>
	</div>
</div>
@endsection
@section('js')
<script type="text/javascript">
	$.ajaxSetup({
		headers:{
			'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
		}
	});


	//绑定单击事件  删除
	$('.del').click(function(){
		var sid = $(this).parents('tr').find('.sorting_1').html();
		var btn = $(this);

		//发送ajax请求
		$.post('/admin/shop/del',{sid:sid},function(data){
			if (data == 2) {
				//删除成功
				alert('删除成功');
				btn.parents('tr').remove();
			}else{
				// 分类下有子分类
				alert('删除失败,该商店下有商品');
			}
		})
	});

	// // 绑定双击事件   修改
	// $('.gradeA').dblclick(function(){

	// })

</script>
@endsection